import Vue from 'vue'
import Router from 'vue-router'
import Layout from '@/views/base/Layout'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/login',
      name: '登陆页面',
      component: () => import('@/views/base/Login')
    },
    {
      path: '/',
      component: Layout,
      redirect: '/main',
      children: [
        {
          path: '/main',
          component: () => import('@/views/base/Main'),
          name: '首页',
          meta: {
            requireAuth: true
          }
        }
      ]
    },
    {
      path: '/sys/user/:id',
      redirect: '/sys/user/:id',
      component: Layout,
      children: [
        {
          path: '/sys/user/adminUser',
          component: () => import('@/views/sys/user/AdminUser/Page'),
          props: (route) => ({ query: route.query.id }),
          name: '操作员管理',
          meta: {
            requireAuth: true
          }
        }
      ]
    },
    {
      path: '/sys/setup/:id',
      redirect: '/sys/setup/:id',
      component: Layout,
      children: [
        {
          path: '/sys/setup/adminMenu',
          component: () => import('@/views/sys/setup/AdminMenu/Page'),
          props: (route) => ({ query: route.query.id }),
          name: '权限管理',
          meta: {
            requireAuth: true
          }
        },
        {
          path: '/sys/setup/dict',
          component: () => import('@/views/sys/setup/Dict/Page'),
          props: (route) => ({ query: route.query.id }),
          name: '数据字典',
          meta: {
            requireAuth: true
          }
        },
      ]
    },
    {
      path: '/qiniu',
      redirect: '/qiniu',
      name: '七牛云上传',
      component: Layout,
      meta: {
        requireAuth: true
      },
      children: [
        {
          path: '/qiniu',
          component: () => import('@/views/qiniu/Qiniu'),
          name: 'Qiniu'
        }
      ]
    },
    {
      path: '/upload',
      redirect: '/upload',
      component: Layout,
      name: '上传视频',
      children: [
        {
          path: '/upload',
          component: () => import('@/views/qiniu/upload'),
          name: 'Upload'
        }
      ]
    },
    {
      path: '*',
      redirect: '/404',
      component: Layout,
      name: '404',
      children: [
        {
          path: '/404',
          component: () => import('@/views/base/error/404'),
          name: 'Error404'
        }
      ]
    }

  ]
})
